package com.javasee.common.dbsharding;

import com.javasee.common.module.ModuleEnable;
import com.javasee.common.module.ModuleEnableConst;
import lombok.Data;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.HashMap;
import java.util.Map;

import static java.util.concurrent.TimeUnit.MINUTES;

@ModuleEnable(ModuleEnableConst.DBSHARDING)
@Data
@ConfigurationProperties(prefix="dbsharding")
public class DbShardingProperties {

    private volatile Integer minIdle = 5;

    private volatile Integer maxIdle = 15;

    private volatile Long maxLifetime = MINUTES.toMillis(3);

    private volatile Long idleTimeout = MINUTES.toMillis(1);

    private volatile Map<String, DataSourceProperties> datasources = new HashMap<>();

    private volatile Map<String, DbShardingTableInfo> tables = new HashMap<>();

    public  final static String mapperScanBasePackages = "com.**.mapper";

    private volatile String mapperXmlClassPath = "classpath*:mapper/*.xml";

    private volatile String typeHandlersPackage = "com.javasee.common.dbsharding.mybatis.typeHandler";

}
